package com.cn.xiaonuo.tcrfinance.tcrgnete.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cn.xiaonuo.tcrfinance.tcrgnete.entiey.PvShopWallet;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PvShopWalletMapper extends BaseMapper<PvShopWallet> {
    /**
     *
     * @param id
     * @param amount 提现金额
     */
    @Update("UPDATE `pv_shop_wallet` SET  " +
            " `available_amount` = case when available_amount - #{amount} <=0 THEN 0 ELSE available_amount - #{amount} END, " +
            "`frozen_amount`=frozen_amount + #{amount} WHERE id=#{id}")
    void updateAmount(@Param("id") Long id, @Param("amount") Long amount);

}
